package com.leha.mp.api.controller;

import com.leha.mp.core.services.BedgeServices;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import utils.APIResult;

@RestController
@Api(value = "/system", description = "系统类API")
@RequestMapping("/system")
@ResponseStatus(HttpStatus.OK)
public class NoticeController {
    @Autowired
    BedgeServices bedgeServices;

    @GetMapping("/user/{userId}/bedge")
    @ApiOperation("获取红点信息_用户端")
    public APIResult getUserBedge(@PathVariable Integer userId) {
        return new APIResult(bedgeServices.getUserBedge(userId));
    }
    @PostMapping("/user/clearBedge")
    @ApiOperation("清除红点信息_用户端")
    public APIResult clearUserBedge(Integer userId, Integer type, Integer refId) {
        if(refId!=null && refId!=0) {
            return new APIResult(bedgeServices.ClearUserBedge(userId, type, refId));
        } else {
            return new APIResult(bedgeServices.ClearUserBedge(userId, type));
        }
    }

    @GetMapping("/doctor/{doctorId}/bedge")
    @ApiOperation("获取红点信息_医生端")
    public APIResult getDoctorBedge(@PathVariable Integer doctorId) {
        return new APIResult(bedgeServices.getUserBedge(-doctorId));
    }
    @PostMapping("/doctor/clearBedge")
    @ApiOperation("清除红点信息_医生端")
    public APIResult clearDoctorBedge(Integer doctorId, Integer type, Integer refId) {
        if(refId!=null && refId!=0) {
            return new APIResult(bedgeServices.ClearUserBedge(-doctorId, type, refId));
        } else {
            return new APIResult(bedgeServices.ClearUserBedge(-doctorId, type));
        }
    }
}
